package coreservlets;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.faces.context.*;
import edu.lcs.jsf.TestInt;

public class RegistrationController {
	TestInt userManager;
	
public String register() {
	userManager.sayHello();
    ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
    HttpServletRequest request = (HttpServletRequest)context.getRequest();
    String email = request.getParameter("form2:email");
    String password = request.getParameter("form2:password");
    if ((email == null) ||
        (email.trim().length() < 3) ||
        (email.indexOf("@") == -1)) {
      return("bad-address");
    } else if ((password == null) ||
               (password.trim().length() < 6)) {
      return("bad-password");
    } else {
      return("success");
    }
  }

public void setUserManager(TestInt testInt) {
	System.out.println("in setter");
	this.userManager = testInt;
}
}
